package extension;

public class EvnsFactory {
    private final Class clazz;

    public EvnsFactory(Class clazz) {
        this.clazz = clazz;
    }

    public Evns create() {
        String args = buildArgsFromEvnsOrDefault("stable");
        return new Evns(args);
    }

    private String buildArgsFromEvnsOrDefault(String args) {
        Evn evns = getAnnotationEvn(clazz);
        if (evns != null) {
            args = evns.value();
        }
        return args;
    }

    private Evn getAnnotationEvn(Class<?> clazz) {
        return clazz.getAnnotation(Evn.class);
    }
}
